home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / cg.lha / cg / src / GramYacc.mi < prev    next >
Text File  |  1992-11-24  |  15KB  |  759 lines

  1. IMPLEMENTATION MODULE GramYacc;
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. IMPORT SYSTEM, System, IO, Tree;
  16. (* line 5 "" *)
  17.  
  18.  
  19. FROM IO        IMPORT WriteS, WriteNl;
  20. FROM StringMem    IMPORT WriteString;
  21. FROM Idents    IMPORT NoIdent, tIdent;
  22. FROM Texts    IMPORT WriteText;
  23. FROM Sets    IMPORT IsElement, Include;
  24. FROM TreeC2    IMPORT TreeIO;
  25.  
  26. FROM Tree    IMPORT
  27.    NoTree    , tTree        , Input        , Reverse    ,
  28.    Class    , NoClass    , Child        , Attribute    ,
  29.    ActionPart    , HasSelector    , HasAttributes    , NoCodeAttr    ,
  30.    Referenced    , Options    , TreeRoot    , QueryTree    ,
  31.    ClassCount    , iNoTree    , itTree    , iModule    ,
  32.    f        , WI, WN    , ForallClasses    , ForallAttributes,
  33.    Nonterminal    , Terminal    , IdentifyAttribute,
  34.    Generated    , String    ;
  35.  
  36. IMPORT Strings;
  37.  
  38. VAR    Node        ,
  39.     ActClass    ,
  40.     TheClass    ,
  41.     TheAttr        : tTree;
  42.     ActActionIndex    ,
  43.     PrevActionIndex    : SHORTCARD;
  44.     IsImplicit    : BOOLEAN;
  45.  
  46. PROCEDURE GetBaseClass (Class: tTree): tTree;
  47.    BEGIN
  48.       WHILE Class^.Class.BaseClass^.Kind # NoClass DO
  49.      Class := Class^.Class.BaseClass;
  50.       END;
  51.       RETURN Class;
  52.    END GetBaseClass;
  53.  
  54. PROCEDURE IsLast (Class, Action: tTree): BOOLEAN;
  55.    VAR Found, Last: BOOLEAN;
  56.    BEGIN
  57.       IsLast2 (Class, Action, Found, Last);
  58.       RETURN Last;
  59.    END IsLast;
  60.  
  61. PROCEDURE IsLast2 (t, Action: tTree; VAR pFound, pLast: BOOLEAN);
  62.    VAR Found, Last: BOOLEAN;
  63.    BEGIN
  64.       CASE t^.Kind OF
  65.       | Class:
  66.         IsLast2 (t^.Class.Attributes, Action, pFound, pLast);
  67.         IF pFound OR NOT pLast THEN RETURN; END;
  68.         IsLast2 (t^.Class.BaseClass, Action, pFound, pLast);
  69.       | Child:
  70.         IsLast2 (t^.Child.Next, Action, Found, Last);
  71.         pFound := Found;
  72.         IF Found THEN
  73.            pLast := Last;
  74.         ELSE
  75.            pLast := FALSE;
  76.         END;
  77.       | Attribute:
  78.         IsLast2 (t^.Attribute.Next, Action, pFound, pLast);
  79.       | ActionPart:
  80.         IsLast2 (t^.ActionPart.Next, Action, Found, Last);
  81.         pFound := Found OR (Action = t);
  82.         IF Found THEN
  83.            pLast := Last;
  84.         ELSE
  85.            pLast := Last AND (Action = t);
  86.         END;
  87.       ELSE
  88.         pFound := FALSE;
  89.         pLast  := TRUE;
  90.       END;
  91.    END IsLast2;
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192. PROCEDURE yyAbort (yyFunction: ARRAY OF CHAR);
  193.  BEGIN
  194.   IO.WriteS (IO.StdError, 'Error: module GramYacc, routine ');
  195.   IO.WriteS (IO.StdError, yyFunction);
  196.   IO.WriteS (IO.StdError, ' failed');
  197.   IO.WriteNl (IO.StdError);
  198.   Exit;
  199.  END yyAbort;
  200.  
  201. PROCEDURE yyIsEqual (yya, yyb: ARRAY OF SYSTEM.BYTE): BOOLEAN;
  202.  VAR yyi    : INTEGER;
  203.  BEGIN
  204.   FOR yyi := 0 TO INTEGER (HIGH (yya)) DO
  205.    IF yya [yyi] # yyb [yyi] THEN RETURN FALSE; END;
  206.   END;
  207.   RETURN TRUE;
  208.  END yyIsEqual;
  209.  
  210. PROCEDURE ParsSpec (t: Tree.tTree);
  211.  VAR yyTempo: RECORD CASE : INTEGER OF
  212.  END; END;
  213.  BEGIN
  214.   IF t = Tree.NoTree THEN RETURN; END;
  215.   IF (t^.Kind = Tree.Ag) THEN
  216. (* line 84 "" *)
  217.      WITH t^.Ag DO
  218. (* line 84 "" *)
  219.       
  220.     WriteS (f, "%{"); WriteNl (f);
  221.     WriteS (f, '# include "Scanner.h"'); WriteNl (f);
  222.     WriteS (f, "/* EXPORT */"); WriteNl (f);
  223.     WriteText (f, ParserCodes^.Codes.Export);
  224.     Node := Modules;
  225.     WHILE Node^.Kind = Tree.Module DO
  226.       WriteText (f, Node^.Module.ParserCodes^.Codes.Export);
  227.       Node := Node^.Module.Next;
  228.     END;
  229.     WriteS (f, "/* GLOBAL */"); WriteNl (f);
  230.     WriteText (f, ParserCodes^.Codes.Global);
  231.     Node := Modules;
  232.     WHILE Node^.Kind = Tree.Module DO
  233.        WriteText (f, Node^.Module.ParserCodes^.Codes.Global);
  234.        Node := Node^.Module.Next;
  235.     END;
  236.     WriteS (f, "/* LOCAL */"); WriteNl (f);
  237.     WriteText (f, ParserCodes^.Codes.Local);
  238.     Node := Modules;
  239.     WHILE Node^.Kind = Tree.Module DO
  240.       WriteText (f, Node^.Module.ParserCodes^.Codes.Local);
  241.       Node := Node^.Module.Next;
  242.     END;
  243.     WriteNl (f);
  244.     WriteS (f, "void BeginParser ()"); WriteNl (f);
  245.     WriteS (f, "{"); WriteNl (f);
  246.     WriteText (f, ParserCodes^.Codes.Begin);
  247.     Node := Modules;
  248.     WHILE Node^.Kind = Tree.Module DO
  249.       WriteText (f, Node^.Module.ParserCodes^.Codes.Begin);
  250.       Node := Node^.Module.Next;
  251.     END;
  252.     WriteS (f, "}"); WriteNl (f);
  253.     WriteNl (f);
  254.     WriteS (f, "void CloseParser ()"); WriteNl (f);
  255.     WriteS (f, "{"); WriteNl (f);
  256.     WriteText (f, ParserCodes^.Codes.Close);
  257.     Node := Modules;
  258.     WHILE Node^.Kind = Tree.Module DO
  259.       WriteText (f, Node^.Module.ParserCodes^.Codes.Close);
  260.       Node := Node^.Module.Next;
  261.     END;
  262.     WriteS (f, "}"); WriteNl (f);
  263.     WriteNl (f);
  264.         ParsVariant (Classes);
  265.     WriteS (f, "%}"); WriteNl (f);
  266.     WriteNl (f);
  267.     WriteS (f, "%union {"); WriteNl (f);
  268.     WriteS (f, " tScanAttribute Scan;"); WriteNl (f);
  269.     Node := Classes;
  270.     WHILE Node^.Kind = Class DO
  271.       WITH Node^.Class DO
  272.          IF {Nonterminal, Referenced, HasAttributes} <= Properties THEN
  273.            IF (String IN Properties) AND NOT (HasSelector IN Properties) THEN
  274.          WriteS (f, " yy"); WN (Name); WriteS (f, " /* "); WI (Name); WriteS (f, " */ yy"); WN (Name); WriteS (f, ";"); WriteNl (f);
  275.            ELSE
  276.          WriteS (f, " yy"); WI (Selector); WriteS (f, " "); WI (Selector); WriteS (f, ";"); WriteNl (f);
  277.            END;
  278.          END;
  279.          Node := Next;
  280.       END;
  281.     END;
  282.     WriteS (f, "}"); WriteNl (f);
  283.     WriteNl (f);
  284.     WriteS (f, "%token"); WriteNl (f);
  285.     ForallClasses (Classes, Token);
  286.     WriteNl (f);
  287.     PrecDefs (Precs);
  288.     WriteNl (f);
  289.     WriteS (f, "%%"); WriteNl (f);
  290.     WriteNl (f);
  291.     ForallClasses (Classes, ParsSpec);
  292. ;
  293.       RETURN;
  294.      END;
  295.  
  296.   END;
  297.   IF (t^.Kind = Tree.Class) THEN
  298. (* line 158 "" *)
  299.      WITH t^.Class DO
  300. (* line 158 "" *)
  301.       
  302.     IF {Nonterminal, Referenced} <= Properties THEN
  303.        TheClass := t;
  304.        Grammar (t);
  305.     END;
  306. ;
  307.       RETURN;
  308.      END;
  309.  
  310.   END;
  311.  END ParsSpec;
  312.  
  313. PROCEDURE ParsVariant (t: Tree.tTree);
  314.  VAR yyTempo: RECORD CASE : INTEGER OF
  315.  END; END;
  316.  BEGIN
  317.   IF t = Tree.NoTree THEN RETURN; END;
  318.   IF (t^.Kind = Tree.Class) THEN
  319. (* line 168 "" *)
  320.      WITH t^.Class DO
  321. (* line 168 "" *)
  322.       
  323.     IF {Nonterminal, Referenced, HasAttributes} <= Properties THEN
  324.       WriteS (f, "typedef struct { "); 
  325.       ForallAttributes (Attributes, RecordField);
  326.       GenExt (Extensions);
  327.           IF (String IN Properties) AND NOT (HasSelector IN Properties) THEN
  328.         WriteS (f, "} /* "); WI (Name); WriteS (f, " */ yy"); WN (Name); WriteS (f, ";"); WriteNl (f);
  329.       ELSE
  330.         WriteS (f, "} yy"); WI (Selector); WriteS (f, ";"); WriteNl (f);
  331.       END;
  332.     END;
  333.     ParsVariant (Next);
  334. ;
  335.       RETURN;
  336.      END;
  337.  
  338.   END;
  339.  END ParsVariant;
  340.  
  341. PROCEDURE GenExt (t: Tree.tTree);
  342.  VAR yyTempo: RECORD CASE : INTEGER OF
  343.  END; END;
  344.  BEGIN
  345.   IF t = Tree.NoTree THEN RETURN; END;
  346.   IF (t^.Kind = Tree.Class) THEN
  347. (* line 185 "" *)
  348.      WITH t^.Class DO
  349. (* line 185 "" *)
  350.       
  351.     ForallAttributes (Attributes, RecordField);
  352.     GenExt (Extensions);
  353.     GenExt (Next);
  354. ;
  355.       RETURN;
  356.      END;
  357.  
  358.   END;
  359.  END GenExt;
  360.  
  361. PROCEDURE Token (t: Tree.tTree);
  362.  VAR yyTempo: RECORD CASE : INTEGER OF
  363.  END; END;
  364.  BEGIN
  365.   IF t = Tree.NoTree THEN RETURN; END;
  366.   IF (t^.Kind = Tree.Class) THEN
  367. (* line 194 "" *)
  368.      WITH t^.Class DO
  369. (* line 194 "" *)
  370.       
  371.     IF {Terminal, Referenced} <= Properties THEN
  372.        WriteS (f, " "); WI (Name); WriteS (f, " "); WN (Code); WriteNl (f);
  373.     END;
  374. ;
  375.       RETURN;
  376.      END;
  377.  
  378.   END;
  379.  END Token;
  380.  
  381. PROCEDURE RecordField (t: Tree.tTree);
  382.  VAR yyTempo: RECORD CASE : INTEGER OF
  383.  END; END;
  384.  BEGIN
  385.   IF t = Tree.NoTree THEN RETURN; END;
  386.   IF (t^.Kind = Tree.Attribute) THEN
  387. (* line 203 "" *)
  388.      WITH t^.Attribute DO
  389. (* line 203 "" *)
  390.       
  391.     IF (NoCodeAttr * Properties) = {} THEN 
  392.        WI (Type); WriteS (f, " "); WI (Name); WriteS (f, "; "); 
  393.     END;
  394. ;
  395.       RETURN;
  396.      END;
  397.  
  398.   END;
  399.  END RecordField;
  400.  
  401. PROCEDURE PrecDefs (t: Tree.tTree);
  402.  VAR yyTempo: RECORD CASE : INTEGER OF
  403.  END; END;
  404.  BEGIN
  405.   IF t = Tree.NoTree THEN RETURN; END;
  406.   IF (t^.Kind = Tree.LeftAssoc) THEN
  407. (* line 212 "" *)
  408.      WITH t^.LeftAssoc DO
  409. (* line 212 "" *)
  410.       
  411.     WriteS (f, "%left "); PrecDefs (Names); WriteNl (f);
  412.     PrecDefs (Next);
  413. ;
  414.       RETURN;
  415.      END;
  416.  
  417.   END;
  418.   IF (t^.Kind = Tree.RightAssoc) THEN
  419. (* line 216 "" *)
  420.      WITH t^.RightAssoc DO
  421. (* line 216 "" *)
  422.       
  423.     WriteS (f, "%right"); PrecDefs (Names); WriteNl (f);
  424.     PrecDefs (Next);
  425. ;
  426.       RETURN;
  427.      END;
  428.  
  429.   END;
  430.   IF (t^.Kind = Tree.NonAssoc) THEN
  431. (* line 220 "" *)
  432.      WITH t^.NonAssoc DO
  433. (* line 220 "" *)
  434.       
  435.     WriteS (f, "%none "); PrecDefs (Names); WriteNl (f);
  436.     PrecDefs (Next);
  437. ;
  438.       RETURN;
  439.      END;
  440.  
  441.   END;
  442.   IF (t^.Kind = Tree.Name) THEN
  443. (* line 224 "" *)
  444.      WITH t^.Name DO
  445. (* line 224 "" *)
  446.       
  447.     WriteS (f, " "); WI (Name);
  448.     PrecDefs (Next);
  449. ;
  450.       RETURN;
  451.      END;
  452.  
  453.   END;
  454.  END PrecDefs;
  455.  
  456. PROCEDURE Grammar (t: Tree.tTree);
  457.  VAR yyTempo: RECORD CASE : INTEGER OF
  458.  END; END;
  459.  BEGIN
  460.   IF t = Tree.NoTree THEN RETURN; END;
  461.   IF (t^.Kind = Tree.Class) THEN
  462. (* line 232 "" *)
  463.      WITH t^.Class DO
  464. (* line 232 "" *)
  465.       
  466.     IF Extensions^.Kind = Tree.NoClass THEN        (* Low ? *)
  467.        WITH TheClass^.Class DO
  468.           IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
  469.        END;
  470.        WriteS (f, "    : "); 
  471.        ActClass := t;
  472.        PrevActionIndex := 0;
  473.        IsImplicit := FALSE;
  474.        ForallAttributes (t, Rule);
  475.        IF Prec # NoIdent THEN WriteS (f, "%prec "); WI (Prec); WriteS (f, " "); END;
  476.        WriteS (f, ";"); WriteNl (f);
  477.        PrevActionIndex := 0;
  478.        IsImplicit := TRUE;
  479.        ForallAttributes (t, Implicit);
  480.     ELSE
  481.        Rule (Extensions);
  482.     END;
  483. ;
  484.       RETURN;
  485.      END;
  486.  
  487.   END;
  488.  END Grammar;
  489.  
  490. PROCEDURE Rule (t: Tree.tTree);
  491.  VAR yyTempo: RECORD CASE : INTEGER OF
  492.  END; END;
  493.  BEGIN
  494.   IF t = Tree.NoTree THEN RETURN; END;
  495.  
  496.   CASE t^.Kind OF
  497.   | Tree.Class:
  498. (* line 255 "" *)
  499.      WITH t^.Class DO
  500. (* line 255 "" *)
  501.       
  502.     Grammar (t);
  503.     Rule (Next);
  504. ;
  505.       RETURN;
  506.      END;
  507.  
  508.   | Tree.Child:
  509. (* line 259 "" *)
  510.      WITH t^.Child DO
  511. (* line 259 "" *)
  512.       
  513.     IF {String, Nonterminal} <= Class^.Class.Properties THEN WriteS (f, "yy"); WN (Type); ELSE WI (Type); END; WriteS (f, " "); 
  514. ;
  515.       RETURN;
  516.      END;
  517.  
  518.   | Tree.ActionPart:
  519. (* line 262 "" *)
  520.      WITH t^.ActionPart DO
  521. (* line 262 "" *)
  522.       
  523.       IF NOT IsElement (ORD ('v'), Options) THEN
  524.     IF IsLast (ActClass, t) THEN
  525.        WriteS (f, "{"); 
  526.        IF PrevActionIndex # 0 THEN
  527.           Node := GetBaseClass (TheClass);
  528.           WITH Node^.Class DO
  529.          WriteS (f, " $$."); 
  530.          IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
  531.          WriteS (f, " = $"); WN (PrevActionIndex); WriteS (f, "."); 
  532.          IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
  533.          WriteS (f, ";"); WriteNl (f);
  534.           END;
  535.        END;
  536.        Rule (Actions);
  537.        WriteS (f, "} "); 
  538.     ELSE
  539.        WriteS (f, "xx"); WN (Name); WriteS (f, " "); 
  540.     END;
  541.     PrevActionIndex := ParsIndex;
  542.       END;
  543. ;
  544.       RETURN;
  545.      END;
  546.  
  547.   | Tree.Assign:
  548. (* line 284 "" *)
  549.      WITH t^.Assign DO
  550. (* line 284 "" *)
  551.       
  552.     Rule (Results); WriteS (f, "="); Rule (Arguments); WriteS (f, ";"); WriteNl (f);
  553.     Rule (Next);
  554. ;
  555.       RETURN;
  556.      END;
  557.  
  558.   | Tree.Copy:
  559. (* line 288 "" *)
  560.      WITH t^.Copy DO
  561. (* line 288 "" *)
  562.       
  563.     Rule (Results); WriteS (f, " = "); Rule (Arguments); WriteS (f, ";"); WriteNl (f);
  564.     Rule (Next);
  565. ;
  566.       RETURN;
  567.      END;
  568.  
  569.   | Tree.TargetCode:
  570. (* line 292 "" *)
  571.      WITH t^.TargetCode DO
  572. (* line 292 "" *)
  573.       
  574.     Rule (Code); WriteS (f, ";"); WriteNl (f);
  575.     Rule (Next);
  576. ;
  577.       RETURN;
  578.      END;
  579.  
  580.   | Tree.Order:
  581. (* line 296 "" *)
  582.      WITH t^.Order DO
  583. (* line 296 "" *)
  584.       
  585.     Rule (Next);
  586. ;
  587.       RETURN;
  588.      END;
  589.  
  590.   | Tree.Check:
  591. (* line 299 "" *)
  592.      WITH t^.Check DO
  593. (* line 299 "" *)
  594.       
  595.     IF Statement # NoTree THEN
  596.        IF Condition # NoTree THEN
  597.           WriteS (f, "if ("); Rule (Condition); WriteS (f, ") ; else { "); Rule (Statement); WriteS (f, " }"); WriteNl (f);
  598.        ELSE
  599.           Rule (Statement);
  600.        END;
  601.     END;
  602.     Rule (Next);
  603. ;
  604.       RETURN;
  605.      END;
  606.  
  607.   | Tree.Designator:
  608. (* line 309 "" *)
  609.      WITH t^.Designator DO
  610. (* line 309 "" *)
  611.       
  612.     TheAttr := IdentifyAttribute (ActClass, Selector);
  613.     IF TheAttr # NoTree THEN
  614.       Node := TheAttr^.Child.Class;
  615.       IF Node # NoTree THEN
  616.         WriteS (f, "$"); 
  617.         IF NOT IsImplicit THEN
  618.            WN (TheAttr^.Child.ParsIndex);
  619.         ELSE
  620.            WN (SHORTINT (TheAttr^.Child.ParsIndex + 1 - ActActionIndex));
  621.         END;
  622.         IF Nonterminal IN Node^.Class.Properties THEN    (* nonterminal *)
  623.           Node := GetBaseClass (Node);
  624.           IF (String IN Node^.Class.Properties) AND NOT (HasSelector IN Node^.Class.Properties) THEN
  625.             WriteS (f, ".yy"); WN (Node^.Class.Name);
  626.           ELSE
  627.             WriteS (f, "."); WI (Node^.Class.Name);
  628.           END;
  629.         ELSE                        (* terminal *)
  630.           IF (String IN Node^.Class.Properties) AND NOT (HasSelector IN Node^.Class.Properties) THEN
  631.             WriteS (f, ".Scan.yy"); WN (Node^.Class.Code);
  632.           ELSE
  633.             WriteS (f, ".Scan."); WI (Node^.Class.Selector);
  634.           END;
  635.         END;
  636.         WriteS (f, "."); WI (Attribute);
  637.       ELSE
  638.         WI (Selector); WriteS (f, ":"); WI (Attribute);
  639.       END;
  640.     ELSE
  641.       WI (Selector); WriteS (f, ":"); WI (Attribute);
  642.     END;
  643.     Rule (Next);
  644. ;
  645.       RETURN;
  646.      END;
  647.  
  648.   | Tree.Ident:
  649. (* line 343 "" *)
  650.      WITH t^.Ident DO
  651. (* line 343 "" *)
  652.       
  653.     TheAttr := IdentifyAttribute (ActClass, Attribute);
  654.     Node := GetBaseClass (TheClass);
  655.     IF TheAttr # NoTree THEN
  656.       IF (String IN Node^.Class.Properties) AND NOT (HasSelector IN Node^.Class.Properties) THEN
  657.         WriteS (f, "$$.yy"); WN (Node^.Class.Name); WriteS (f, "."); WI (Attribute);
  658.       ELSE
  659.         WriteS (f, "$$."); WI (Node^.Class.Name); WriteS (f, "."); WI (Attribute);
  660.       END;
  661.     ELSE
  662.       WI (Attribute);
  663.     END;
  664.     Rule (Next);
  665. ;
  666.       RETURN;
  667.      END;
  668.  
  669.   | Tree.Any:
  670. (* line 357 "" *)
  671.      WITH t^.Any DO
  672. (* line 357 "" *)
  673.       
  674.     WriteString (f, Code);
  675.     Rule (Next);
  676. ;
  677.       RETURN;
  678.      END;
  679.  
  680.   | Tree.Anys:
  681. (* line 361 "" *)
  682.      WITH t^.Anys DO
  683. (* line 361 "" *)
  684.       
  685.     Rule (Layouts);
  686.     Rule (Next);
  687. ;
  688.       RETURN;
  689.      END;
  690.  
  691.   | Tree.LayoutAny:
  692. (* line 365 "" *)
  693.      WITH t^.LayoutAny DO
  694. (* line 365 "" *)
  695.       
  696.     WriteString (f, Code);
  697.     Rule (Next);
  698. ;
  699.       RETURN;
  700.      END;
  701.  
  702.   ELSE END;
  703.  
  704.  END Rule;
  705.  
  706. PROCEDURE Implicit (t: Tree.tTree);
  707.  VAR yyTempo: RECORD CASE : INTEGER OF
  708.  END; END;
  709.  BEGIN
  710.   IF t = Tree.NoTree THEN RETURN; END;
  711.   IF (t^.Kind = Tree.ActionPart) THEN
  712. (* line 373 "" *)
  713.      WITH t^.ActionPart DO
  714. (* line 373 "" *)
  715.       
  716.     IF NOT (Generated IN Properties) AND NOT IsLast (ActClass, t) THEN
  717.        INCL (Properties, Generated);
  718.        ActActionIndex := ParsIndex;
  719.        WriteS (f, "xx"); WN (Name); WriteS (f, "    : {"); 
  720.        IF PrevActionIndex # 0 THEN
  721.           Node := GetBaseClass (TheClass);
  722.           WITH Node^.Class DO
  723.          WriteS (f, " $$."); 
  724.          IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
  725.          WriteS (f, " = $"); WN (SHORTINT (PrevActionIndex + 1 - ActActionIndex)); WriteS (f, "."); 
  726.          IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
  727.          WriteS (f, ";"); WriteNl (f);
  728.           END;
  729.        END;
  730.        Rule (Actions);
  731.        WriteS (f, "} ."); WriteNl (f);
  732.     END;
  733.     PrevActionIndex := ParsIndex;
  734. ;
  735.       RETURN;
  736.      END;
  737.  
  738.   END;
  739.  END Implicit;
  740.  
  741. PROCEDURE BeginGramYacc;
  742.  BEGIN
  743.  END BeginGramYacc;
  744.  
  745. PROCEDURE CloseGramYacc;
  746.  BEGIN
  747.  END CloseGramYacc;
  748.  
  749. PROCEDURE yyExit;
  750.  BEGIN
  751.   IO.CloseIO; System.Exit (1);
  752.  END yyExit;
  753.  
  754. BEGIN
  755.  yyf    := IO.StdOutput;
  756.  Exit    := yyExit;
  757.  BeginGramYacc;
  758. END GramYacc.
  759.